﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using SecurityApi.Business;
using SecurityApi.DataAccess;

namespace SecurityApi.WebApi.Controllers
{
    public class UserController : ApiController
    {
        public IEnumerable<SecurityApi.Model.EnterpriseUser> Get()
        {
            EnterpriseUserRepository repository = new EnterpriseUserRepository();
            var query = repository.GetAll();
            return query.ToList();
        }

        public SecurityApi.DataAccess.EnterpriseUser Get(int id)
        {
            EnterpriseUserRepository repository = new EnterpriseUserRepository();
            var user = repository.GetUserById(id);
            return user;
        }

        [HttpGet]
        public bool VerifyUser(string userName,string password,int enterpriseId)
        {
            UserManager mgr = new UserManager();
            bool bResult = mgr.VerifyPassword(userName, password, enterpriseId);
            return bResult;
        }

        [HttpGet]
        public SecurityApi.Model.EnterpriseUser GetEnterpriseUser(string userName, int enterpriseId)
        {
            UserManager mgr = new UserManager();
            SecurityApi.Model.EnterpriseUser user = mgr.GetEnterpriseUser(userName, enterpriseId);
            return user;
        }

    }
}
